import requests
import re
import time
from bs4 import BeautifulSoup

local = time.strftime("%Y.%m.%d")
url = 'https://cn.bing.com'
con = requests.get(url)
content = con.text
main_page = BeautifulSoup(content, "html.parser")  # 指定HTML解析器
a = main_page.find('link', id='bgLink').get('href')
# reg = r"(az/hprichbg/rb/.*?.jpg)"
# a = re.findall(reg, content, re.S)[0]
print(a)  # /th?id=OHR.CowbirdsEgg_ZH-CN2642512087_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp
picUrl = url + a  # https://cn.bing.com/th?id=OHR.CowbirdsEgg_ZH-CN2642512087_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp
read = requests.get(picUrl)
f = open(f'{local}.jpg', mode='wb')
f.write(read.content)
f.close()